import dayjs from 'dayjs';
import mongoose, { Schema, Document } from 'mongoose';

export interface IFile {
	_id: string;
	name: string;
	originalName: string;
	mimeType: string;
	md5: string;
	path: string;
	url: string;
	uploadTime: string;
	size: number;
}

const FileSchema = new Schema<IFile>({
	name: { type: String, required: true },
	originalName: { type: String, required: true },
	mimeType: { type: String, required: true },
	md5: { type: String, required: true },
	path: { type: String, required: true },
	url: { type: String, required: true },
	size: { type: Number, required: true },
	uploadTime: { type: String, default: () => dayjs().format('YYYY年MM月DD日 HH:mm:ss') },
});

export const FileModel = mongoose.model<IFile>('File', FileSchema);
